package com.watereast;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.Set;
import redis.clients.jedis.Jedis;

public class RedisKeysExample {
    public static void main(String[] args) throws IOException {
        Jedis jedis = new Jedis("10.186.67.16", 31002);
        jedis.auth("Zdnsx@2017");
        Set<String> keys = jedis.keys("*grejwionuserInfonew*");
        System.out.println(keys.size());
        String fileName = "C:\\Users\\nietao-002\\Desktop\\outcai16-31002.txt";
        PrintStream console = System.out;
        FileOutputStream fileOutputStream = new FileOutputStream(fileName);
        PrintStream printStream = new PrintStream(fileOutputStream);
        System.setOut(printStream);
        for (String key : keys)
            System.out.println(key);
        System.setOut(console);
        System.out.println(");
                jedis.close();
    }
}
